﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace WebApi_SY.Models
{

    /// <summary>
    /// sli_SP_InStock 类用于解析星空的入库单数据。
    /// </summary>
    public class sli_InStock
    {
        [JsonProperty("NeedUpDateFields")]
        public List<string> NeedUpDateFields { get; set; }

        [JsonProperty("NeedReturnFields")]
        public List<string> NeedReturnFields { get; set; }

        [JsonProperty("IsDeleteEntry")]
        public string IsDeleteEntry { get; set; }

        [JsonProperty("SubSystemId")]
        public string SubSystemId { get; set; }

        [JsonProperty("IsVerifyBaseDataField")]
        public string IsVerifyBaseDataField { get; set; }

        [JsonProperty("IsEntryBatchFill")]
        public string IsEntryBatchFill { get; set; }

        [JsonProperty("ValidateFlag")]
        public string ValidateFlag { get; set; }

        [JsonProperty("NumberSearch")]
        public string NumberSearch { get; set; }

        [JsonProperty("IsAutoAdjustField")]
        public string IsAutoAdjustField { get; set; }

        [JsonProperty("InterationFlags")]
        public string InterationFlags { get; set; }

        [JsonProperty("IgnoreInterationFlag")]
        public string IgnoreInterationFlag { get; set; }

        [JsonProperty("IsControlPrecision")]
        public string IsControlPrecision { get; set; }

        [JsonProperty("ValidateRepeatJson")]
        public string ValidateRepeatJson { get; set; }

        [JsonProperty("Model")]
        public RequestModel Model { get; set; }
    }

    public class RequestModel
    {
        [JsonProperty("FID")]
        public int FID { get; set; }

        [JsonProperty("FBillType")]
        public NumberField FBillType { get; set; }

        [JsonProperty("FDate")]
        public DateTime ? FDate { get; set; }

        [JsonProperty("FStockOrgId")]
        public NumberField FStockOrgId { get; set; }

        [JsonProperty("FPrdOrgId")]
        public NumberField FPrdOrgId { get; set; }

        [JsonProperty("FCurrId")]
        public NumberField FCurrId { get; set; }

        [JsonProperty("FOwnerTypeId0")]
        public string FOwnerTypeId0 { get; set; }

        [JsonProperty("FOwnerId0")]
        public NumberField FOwnerId0 { get; set; }

        [JsonProperty("FTransferBizTypeId")]
        public NumberField FTransferBizTypeId { get; set; }
        public string FBillNo { get; set; }

        [JsonProperty("FEntity")]
        public List<EntityItem> FEntity { get; set; }
    }

    public class NumberField
    {
        [JsonProperty("FNumber")]
        public string FNumber { get; set; }
    }

    public class EntityItem
    {
        [JsonProperty("FMaterialId")]
        public NumberField FMaterialId { get; set; }

        [JsonProperty("FInStockType")]
        public string FInStockType { get; set; }

        [JsonProperty("FUnitID")]
        public NumberField FUnitID { get; set; }

        [JsonProperty("FMustQty")]
        public double ? FMustQty { get; set; }

        [JsonProperty("FRealQty")]
        public double ? FRealQty { get; set; }

        [JsonProperty("FStockId")]
        public NumberField FStockId { get; set; }

        [JsonProperty("FLot")]
        public NumberField FLot { get; set; }

        [JsonProperty("FWorkShopId1")]
        public NumberField FWorkShopId1 { get; set; }

        [JsonProperty("FProductNo")]
        public string FProductNo { get; set; }

        [JsonProperty("FIsAffectCost")]
        public bool FIsAffectCost { get; set; }

        [JsonProperty("FOwnerTypeId")]
        public string FOwnerTypeId { get; set; }

        [JsonProperty("FOwnerId")]
        public NumberField FOwnerId { get; set; }

        [JsonProperty("FStockUnitId")]
        public NumberField FStockUnitId { get; set; }

        [JsonProperty("FStockRealQty")]
        public double ? FStockRealQty { get; set; }

        [JsonProperty("FBaseUnitId")]
        public NumberField FBaseUnitId { get; set; }

        [JsonProperty("FBaseRealQty")]
        public double ? FBaseRealQty { get; set; }

        [JsonProperty("FExtAuxUnitQty")]
        public double FExtAuxUnitQty { get; set; }

        [JsonProperty("FStockStatusId")]
        public NumberField FStockStatusId { get; set; }

        [JsonProperty("FSecRealQty")]
        public double FSecRealQty { get; set; }

        [JsonProperty("FBaseMustQty")]
        public double ? FBaseMustQty { get; set; }

        [JsonProperty("FKeeperTypeId")]
        public string FKeeperTypeId { get; set; }

        [JsonProperty("FKeeperId")]
        public NumberField FKeeperId { get; set; }
    }

    public class sli_SP_InStock
    {
        [Key]
        public int FID { get; set; }
        public string FBillNo { get; set; }
        public DateTime? FDate { get; set; }
        public int? FLag { get; set; }
        public string FParms { get; set; }
        public virtual ICollection<sli_SP_InStockEntry> sli_SP_InStockEntry { get; set; }
    }

    public class sli_SP_InStockEntry
    {

        public int FID { get; set; }
        [Key]
        public int FEntryID { get; set; }
        public string FMaterialNumber { get; set; }
        public string FBatchNo { get; set; }
        public string FWorkShopNumber { get; set; }
        public string FStockNumber { get; set; }
        public int? FQty { get; set; }
        public virtual sli_SP_InStock sli_SP_InStock { get; set; }
    }



    public class sli_SP_InStock_view
    {
        [Key]
        public int FID { get; set; }  //ID
        public string FBillNo { get; set; }  //单据编号
        public DateTime? FDate { get; set; } //日期
        public int? FLag { get; set; }  //同步标记 (0.未同步/1.已同步/2.同步失败)
        public string FParms { get; set; }  //同步参数
        public virtual ICollection<sli_SP_InStockEntry_view> sli_SP_InStockEntry_view { get; set; }
    }

    public class sli_SP_InStockEntry_view
    {

        public int FID { get; set; }   //关联表头ID
        [Key]
        public int FEntryID { get; set; }  //表体ID
        public string FMaterialNumber { get; set; }  //物料代码
        public string FNAME { get; set; }  //物料名称
        public string FBatchNo { get; set; }  //批号
        public string FWorkShopNumber { get; set; }  //车间代码
        public string FDepName { get; set; }  //车间名称
        public string FStockNumber { get; set; }   //仓库代码
        public string FStockName { get; set; }   //仓库名称
        public int? FQty { get; set; }   //  入库数量
        public virtual sli_SP_InStock_view sli_SP_InStock_view { get; set; }
    }

}